~ubuntu-branches/ubuntu/wily/julia/wily

« back to all changes in this revision

Viewing changes to base/stream.jl

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-02-11 03:51:26 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130211035126-hap464pbhd97wjbl
Tags: 0.1~20130211.git86fbe98d-1
* New upstream snapshot.
* debian/control:
   + add git to Recommends (for Julia package manager)
   + remove dependencies on libglpk-dev (it moved to its own package)
   + add explicit dependency on libgmp10 (there is no more a wrapper)
* fix-clean-rules.patch: remove patch, applied upstream
* gsvddense_blasint.patch: new patch
* Refresh other patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    WaitTask(task::Task) = new(task, false, nothing)
14
14
end
15
15
 
16
 
abstract AsyncStream <: Stream
 
16
abstract AsyncStream <: IO
17
17
 
18
18
typealias UVHandle Ptr{Void}
19
19
typealias UVStream AsyncStream
28
28
 
29
29
type NamedPipe <: AsyncStream
30
30
    handle::Ptr{Void}
31
 
    buffer::Buffer
 
31
    buffer::IOBuffer
32
32
    open::Bool
33
33
    line_buffered::Bool
34
34
    readcb::Callback
35
35
    readnotify::Vector{WaitTask}
36
36
    closecb::Callback
37
37
    closenotify::Vector{WaitTask}
38
 
    NamedPipe() = new(C_NULL,PipeString(),false,true,false,WaitTask[],false,
 
38
    NamedPipe() = new(C_NULL,PipeBuffer(),false,true,false,WaitTask[],false,
39
39
                      WaitTask[])
40
40
end
41
41
 
45
45
    handle::Ptr{Void}
46
46
    open::Bool
47
47
    line_buffered::Bool
48
 
    buffer::Buffer
 
48
    buffer::IOBuffer
49
49
    readcb::Callback
50
50
    readnotify::Vector{WaitTask}
51
51
    closecb::Callback
52
52
    closenotify::Vector{WaitTask}
53
 
    TTY(handle,open)=new(handle,open,true,PipeString(),false,WaitTask[],false,WaitTask[])
 
53
    TTY(handle,open)=new(handle,open,true,PipeBuffer(),false,WaitTask[],false,WaitTask[])
54
54
end
55
55
 
56
56
show(io::IO,stream::TTY) = print(io,"TTY(",stream.open?"connected,":"disconnected,",nb_available(stream.buffer)," bytes waiting)")
90
90
    end
91
91
end
92
92
 
 
93
flush(::TTY) = nothing
93
94
 
94
95
## SOCKETS ##
95
96
 
106
107
            push!(newwts,wt)
107
108
        end
108
109
    end
109
 
    grow!(waittasks,length(newwts)-length(waittasks))
 
110
    resize!(waittasks,length(newwts))
110
111
    waittasks[:] = newwts
111
112
end
112
113
 
204
205
 
205
206
## BUFFER ##
206
207
## Allocate a simple buffer
207
 
function alloc_request(buffer::IOString, recommended_size::Int32)
 
208
function alloc_request(buffer::IOBuffer, recommended_size::Int32)
208
209
    ensureroom(buffer, int(recommended_size))
209
210
    ptr = buffer.append ? buffer.size + 1 : buffer.ptr
210
211
    return (pointer(buffer.data, ptr), length(buffer.data)-ptr+1)
215
216
    (buf,int32(size))
216
217
end
217
218
 
218
 
function notify_filled(buffer::IOString, nread::Int, base::Ptr{Void}, len::Int32)
 
219
function notify_filled(buffer::IOBuffer, nread::Int, base::Ptr{Void}, len::Int32)
219
220
    if buffer.append
220
221
        buffer.size += nread
221
222
    else
272
273
        this
273
274
    end
274
275
end
 
276
SingleAsyncWork(cb::Function) = SingleAsyncWork(eventloop(),cb)
275
277
 
276
278
type IdleAsyncWork <: AsyncWork
277
279
    cb::Function
282
284
        this
283
285
    end
284
286
end
 
287
IdleAsyncWork(cb::Function) = IdleAsyncWork(eventloop(),cb)
285
288
 
286
289
type TimeoutAsyncWork <: AsyncWork
287
290
    cb::Function
292
295
        this
293
296
    end
294
297
end
295
 
 
296
 
const dummySingleAsync = SingleAsyncWork(C_NULL,()->nothing)
 
298
TimeoutAsyncWork(cb::Function) = TimeoutAsyncWork(eventloop(),cb)
297
299
 
298
300
function _uv_hook_close(uv::AsyncStream)
299
301
    uv.handle = 0
306
308
# This serves as a common callback for all async classes
307
309
_uv_hook_asynccb(async::AsyncWork, status::Int32) = async.cb(status)
308
310
 
309
 
function startTimer(timer::TimeoutAsyncWork,timeout::Int64,repeat::Int64)
 
311
function start_timer(timer::TimeoutAsyncWork,timeout::Int64,repeat::Int64)
310
312
    ccall(:jl_timer_start,Int32,(Ptr{Void},Int64,Int64),timer.handle,timeout,repeat)
311
313
end
312
314
 
313
 
function stopTimer(timer::TimeoutAsyncWork)
 
315
function stop_timer(timer::TimeoutAsyncWork)
314
316
    ccall(:jl_timer_stop,Int32,(Ptr{Void},),timer.handle)
315
317
end
316
318
 
327
329
end
328
330
 
329
331
## event loop ##
330
 
globalEventLoop() = ccall(:jl_global_event_loop,Ptr{Void},())
 
332
eventloop() = ccall(:jl_global_event_loop,Ptr{Void},())
331
333
#mkNewEventLoop() = ccall(:jl_new_event_loop,Ptr{Void},()) # this would be fine, but is nowhere supported
332
334
 
333
335
function run_event_loop(loop::Ptr{Void})
334
336
    ccall(:jl_run_event_loop,Void,(Ptr{Void},),loop)
335
337
end
336
 
run_event_loop() = run_event_loop(globalEventLoop())
 
338
run_event_loop() = run_event_loop(eventloop())
337
339
 
338
340
##pipe functions
339
341
malloc_pipe() = c_malloc(_sizeof_uv_pipe)
452
454
 
453
455
## Libuv error handling
454
456
_uv_lasterror(loop::Ptr{Void}) = ccall(:jl_last_errno,Int32,(Ptr{Void},),loop)
455
 
_uv_lasterror() = _uv_lasterror(globalEventLoop())
 
457
_uv_lasterror() = _uv_lasterror(eventloop())
456
458
_uv_lastsystemerror(loop::Ptr{Void}) = ccall(:jl_last_errno,Int32,(Ptr{Void},),loop)
457
 
_uv_lastsystemerror() = _uv_lasterror(globalEventLoop())
 
459
_uv_lastsystemerror() = _uv_lasterror(eventloop())
458
460
 
459
461
type UVError <: Exception
460
462
    prefix::String